pluck
pluck!
is a macro that creates a lambda that plucks the provided
property from the argument. Great with iterators.
Access
pluck!
provides many different ways to access values.
Tuple Indices
Provide the index to extract.
let list = ;
let first = list.iter.map.;
assert_eq!;
let second = list.iter.map.;
assert_eq!;
Struct Properties
Provide the property name to extract.
let list = ;
let names = list.iter.map.;
assert_eq!;
By Reference
Precede the property name with &
to pluck by reference.
let list = ;
let first = list.iter.map.;
assert_eq!;
Mutable Reference
Precede the property name with &mut
to pluck by mutable reference.
let mut list = ;
for num in list.iter_mut.map
assert_eq!;
Index Type
pluck!
works with types implementing Index
and
IndexMut
.
let list = ;
let first = list.iter.map.;
assert_eq!;
let first_ref = list.iter.map.;
assert_eq!;
Deref
pluck!
works with types implementing Deref
and
DerefMut
.
let list = vec!;
let derefed = list.into_iter.map.;
assert_eq!;
let list = vec!;
let derefed = list.into_iter.map.;
assert_eq!;
Combinations
pluck!
is designed to allow you to arbitrarily combine accessing. You
can specify precedence with ()
.
let mut list = vec!;
let derefed = list.iter_mut.map.;
assert_eq!;